home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Singles Flirt Up Your Life! (German)
/
Singles Flirt Up Your Life.iso
/
data1.cab
/
Statemachine
/
staircase.lua
< prev
next >
Wrap
Text File
|
2004-01-29
|
7KB
|
194 lines
-- bed state machine
beginStateMachine()
onMsg("buildMenu", function(msg)
local currentCharacter = getStateObjectFromID(msg.sender);
-- build the pie menu
clearPieMenu();
local button;
local neverFail = CharacterAI.checkFailing(CharacterAI.NEVER_FAIL);
if currentCharacter and (currentCharacter.timeForWork() or neverFail) then
button = addPieMenuButton("pm_gotoWork", "work");
button.addDescription(ACTIVITY, "work");
end
if currentCharacter and (canLeave(currentCharacter) or neverFail) then
button = addPieMenuButton(getLeaveButtonText(this), "changeHouse", "active");
button.addDescription(NO_AI, "true");
end
-- if canGoTo(CITY, this) then
-- button = addPieMenuButton("pm_gotoCity", "changeHouse");
-- end
--button = addPieMenuButton("Einkaufen gehen", "shop"); -- no game play function yet
-- button.addDescription(ACTIVITY, "shop");
--button = addPieMenuButton("pm_goOut", "out");
-- button.addDescription(ACTIVITY, "out");
local otherCharacter = getOtherCharacter(currentCharacter);
if (otherCharacter and activityPossible(currentCharacter, "giveGift", otherCharacter)) then
button = addPieMenuButton("pm_goBuyGift", "gift");
button.addDescription(ACTIVITY, "buyGift");
button.addDescription(NO_AI, "true");
end;
end )
-- go to work
onMsg("work", function(msg)
-- get the game object server
local gameObjectServer = getGameObjectServer();
-- get character who initiated this action
local character = getStateObjectFromID(msg.sender);
local neverFail = CharacterAI.checkFailing(CharacterAI.NEVER_FAIL);
if (not character.timeForWork()) and (not neverFail) then
print("not time for work");
instantAbort(character, EMOTICON_CANNOT, "emoThink");
return
end
-- if character is too unhappy: abort characters action
if instantAbortIfUnhappy(character, "work", this) then return end;
-- walk to the closest action point
local actionPoint = character.getClosestFreeActionPointToClickPoint(this, {"topStep"});
if (actionPoint) then
-- get the walk state object
local wso = character.walkSO;
-- create state machine contexts
local wsoContext = StateMachineContext();
-- store the action point
wsoContext.storeData("actionPointName", actionPoint.getName());
if (wso.walkToActionPoint(actionPoint)) then
wso.queueStateMachine("staircaseChar.goToWork", this, wsoContext);
else
print("no path found");
instantAbort(character, EMOTICON_NOPATH, "emoThink")
end
else
print("no action point found");
instantAbort(character, EMOTICON_CANNOT, "emoThink")
end
end )
-- go shopping
onMsg("shop", function(msg)
-- get the game object server
local gameObjectServer = getGameObjectServer();
-- get character who initiated this action
local character = getStateObjectFromID(msg.sender);
-- walk to the closest action point
local actionPoint = character.getClosestFreeActionPointToClickPoint(this, {"topStep"});
if (actionPoint) then
-- get the walk state object
local wso = character.walkSO;
-- create state machine contexts
local wsoContext = StateMachineContext();
-- store the action point
wsoContext.storeData("actionPointName", actionPoint.getName());
if (wso.walkToActionPoint(actionPoint)) then
wso.queueStateMachine("staircaseChar.goToShop", this, wsoContext);
else
print("no path found (in staircase.lua onMsg shop)");
instantAbort(character, EMOTICON_NOPATH, "emoThink")
end
else
print("no action point found (in staircase.lua onMsg shop)");
instantAbort(character, EMOTICON_CANNOT, "emoThink")
end
end )
-- go shopping
onMsg("out", function(msg)
-- get the game object server
local gameObjectServer = getGameObjectServer();
-- get character who initiated this action
local character = getStateObjectFromID(msg.sender);
-- walk to the closest action point
local actionPoint = character.getClosestFreeActionPointToClickPoint(this, {"topStep"});
if (actionPoint) then
-- get the walk state object
local wso = character.walkSO;
-- create state machine contexts
local wsoContext = StateMachineContext();
-- store the action point
wsoContext.storeData("actionPointName", actionPoint.getName());
if (wso.walkToActionPoint(actionPoint)) then
wso.queueStateMachine("staircaseChar.goToShop", this, wsoContext);
else
print("no path found (in staircase.lua onMsg shop)");
instantAbort(character, EMOTICON_NOPATH, "emoThink")
end
else
print("no action point found (in staircase.lua onMsg shop)");
instantAbort(character, EMOTICON_CANNOT, "emoThink")
end
end )
-- go shopping
onMsg("gift", function(msg)
-- get the game object server
local gameObjectServer = getGameObjectServer();
-- get character who initiated this action
local character = getStateObjectFromID(msg.sender);
-- walk to the closest action point
local actionPoint = character.getClosestFreeActionPointToClickPoint(this, {"topStep"});
if (actionPoint) then
-- get the walk state object
local wso = character.walkSO;
-- create state machine contexts
local wsoContext = StateMachineContext();
-- store the action point
wsoContext.storeData("actionPointName", actionPoint.getName());
if (wso.walkToActionPoint(actionPoint)) then
wso.queueStateMachine("staircaseChar.goBuyGift", this, wsoContext);
else
print("no path found (in staircase.lua onMsg gift)");
instantAbort(character, EMOTICON_NOPATH, "emoThink")
end
else
print("no action point found (in staircase.lua onMsg gift)");
instantAbort(character, EMOTICON_CANNOT, "emoThink")
end
end )
-- go shopping
onMsg("changeHouse", function(msg)
-- get the game object server
local gameObjectServer = getGameObjectServer();
-- get character who initiated this action
local character = getStateObjectFromID(msg.sender);
-- walk to the closest action point
local actionPoint = character.getClosestFreeActionPointToClickPoint(this, {"topStep"});
if (actionPoint) then
-- get the walk state object
local wso = character.walkSO;
-- create state machine contexts
local wsoContext = StateMachineContext();
-- store the action point
wsoContext.storeData("actionPointName", actionPoint.getName());
wsoContext.storeData("activePart", not(msg.data == ""));
if (wso.walkToActionPoint(actionPoint)) then
wso.queueStateMachine("staircaseChar.goToOtherHouse", this, wsoContext);
else
print("no path found (in staircase.lua onMsg gift)");
instantAbort(character, EMOTICON_NOPATH, "emoThink")
end
else
print("no action point found (in staircase.lua onMsg gift)");
instantAbort(character, EMOTICON_CANNOT, "emoThink")
end
end )
endStateMachine()